﻿using StudentManage.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using StudentManage.SQLBase;

namespace StudentManage.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            StudentInfo aa = new StudentInfo();
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
        /// <summary>
        /// 学生信息录入
        /// </summary>
        /// <returns></returns>
        public ActionResult StudentLR()
        {
            return View();
        }
        /// <summary>
        /// 学生信息表格显示
        /// </summary>
        /// <returns></returns>
        public ActionResult StudentXS()
        {
            var strsql = "select * from StudentInfo";//TODO 这里写查询语句
            var sqlComm = new SqlDataBase();//我写好的处理数据库连接的类
            DataTable dt = sqlComm.ExecuteDataTable(strsql);//执行SQL语句，并返回DataTable
           List<StudentInfo> lst=new List<StudentInfo>();
            sqlComm.Close();
            return View(lst);
        }
        public ActionResult SaveStudentInfo(StudentInfo model)                                                             
        {
            string sql = "insert into StudentInfo (studentName,age,gender,stat,createdTime)values('学生A',20,1,1,'2017')";//TODO 这里写插入语句
            var sqlComm = new SqlDataBase();
            var result = sqlComm.ExecuteNonQuery(sql);//执行SQL语句，并返回影响行数
            sqlComm.Close();
            return RedirectToAction("StudentLR");
        }
      
    }
}